package com.example.work_study_system.web.controller;


import com.example.work_study_system.model.domain.Position;
import com.example.work_study_system.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/position")
public class PositionController {
    @Autowired
    private PositionService positionService;

    @GetMapping("/list")
    public List<Position> list() {
        return positionService.list();
    }

    @GetMapping("/{id}")
    public Position getById(@PathVariable Integer id) {
        return positionService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Position position) {
        return positionService.save(position);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Position position) {
        return positionService.updateById(position);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return positionService.removeById(id);
    }
} 